Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UB in GenericMemoryAllocator::deallocate #2572

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

marc0246
Copy link
Contributor

@marc0246 marc0246 commented Oct 7, 2024

The code was UB for a two different reasons. First, the block pointer given out on allocation went through Box::deref_mut, which means that each new allocation made would invalidate pointers in previous allocations, in both SB and TB. Second, in SB, moving a Box asserts uniqueness, which happens when sorting the vec containing the boxes.

Sounds quite horrible, but thankfully, what's saving us is that deallocate is only ever called via dynamic dispatch unless you call it yourself. There's no way to take advantage of UB happening across dynamic dispatch calls.

Changelog:

### Bugs fixed
- Fixed UB in `GenericMemoryAllocator::deallocate` arising due to invalid pointer provenance given out on allocation.

@Rua Rua merged commit 3189169 into vulkano-rs:master Oct 10, 2024
6 checks passed
@marc0246 marc0246 deleted the memory-allocator-ub branch October 10, 2024 13:17
marc0246 added a commit that referenced this pull request Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants